SHELL = @SHELL@
CC    = @CC@
F77   = @F77@
CXX   = @CXX@
F90   = @F90@
MAKE  = @MAKE@
LIBS  = @LIBS@
MPIRUN= @MPIRUN@
NP_ARG= @NP_ARG@

all: all-redirect

PROGRAMS = pi3 cpi pi pit matvec matmat matmatlog monte 
SOURCES  = pi3.f cpi.c pi.cc pit.f matvec.f matmat.f matmatlog.f monte.c

all-redirect: ${PROGRAMS}

clean:
	rm -rf *.o ${PROGRAMS} *~ PI* @CXX_TEMPLATE_DIR@
	(cd f90 ; ${MAKE} clean)

.SUFFIXES: .o .c .f .cc .f90
.c:
	${CC} ${CFLAGS} -o $* $< ${LIBS} 
.c.o:
	${CC} ${CFLAGS} -c $<
.f:
	${F77} ${FFLAGS} -o $* $< ${LIBS}
.f.o:
	${F77} ${FFLAGS} -c $<
.f90:
	${F90} ${F90FLAGS} -o $* $< ${LIBS}
.cc:
	${CXX} ${CXXFLAGS} -o $* $< ${LIBS} 

matmatlog: matmatlog.o
	${F77} ${FFLAGS} -o matmatlog matmatlog.o -lmpe ${LIBS}
monte: monte.o
	${CC} ${CFLAGS} -o monte monte.o -lmpe ${LIBS} 

run: ${PROGRAMS}
	${MPIRUN} ${NP_ARG} 2 cpi
	${MPIRUN} ${NP_ARG} 2 pi
	${MPIRUN} ${NP_ARG} 2 pit
	${MPIRUN} ${NP_ARG} 4 matvec
	${MPIRUN} ${NP_ARG} 4 matmat

sources:
	@echo ${SOURCES}
